/*
 * 得到省份
 */
function getOrgProvince(provinceId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getProvinceUrl,
        data: {
        },
        success: function (data) {
            var optionStr = "<option value=''>州</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (provinceId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='org_province_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}
/*
 * 得到城市
 */
function getOrgCity(provinceId, cityId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getCityUrl,
        data: {
            province_id: provinceId
        },
        success: function (data) {
            var optionStr = "<option value='0'>城市</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (cityId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='org_city_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}
/*
 * 得到区县
 */
function getOrgDistrict(cityId, districtId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getDistrictUrl,
        data: {
            "city_id": cityId
        },
        success: function (data) {
            var optionStr = "<option value='0'>区县</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (districtId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='org_district_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}

//改变省份
function changeOrgProvince(provinceId, frm) {
    return;
    var optionStr = "<option value='0'>城市</option>";
    var optionCityStr = "<option value='0'>区县</option>";
    if (provinceId > 0) {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: getCityUrl,
            data: {
                province_id: provinceId
            },
            success: function (data) {
                var optionStr = "<option value='0'>城市</option>";
                for (var i in data) {
                    optionStr = optionStr + "<option value = '" + data[i].id + "'>" + data[i].name + "</option>";
                }
                $("select[name=org_city_id]").html(optionStr);
                frm.render('select'); //刷新select选择框渲染
            }
        });
    } else {
        $("select[name=org_city_id]").html(optionStr);
        frm.render('select'); //刷新select选择框渲染
    }
    $("select[name=org_district_id]").html(optionCityStr);
    frm.render('select'); //刷新select选择框渲染
}

//改变区县
function changeOrgCity(cityId, frm) {
    var optionStr = "<option value='0'>区县</option>";
    if (cityId > 0) {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: getDistrictUrl,
            data: {
                "city_id": cityId
            },
            success: function (data) {
                var optionStr = "<option value='0'>区县</option>";
                for (var i in data) {
                    optionStr = optionStr + "<option value = '" + data[i].id + "'>" + data[i].name + "</option>";
                }
                $("select[name=org_district_id]").html(optionStr);
                frm.render('select'); //刷新select选择框渲染
            }
        });
    } else {
        $("select[name=org_district_id]").html(optionStr);
        frm.render('select'); //刷新select选择框渲染
    }
}

/*
 * 得到省份
 */
function getDestProvince(provinceId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getProvinceUrl,
        data: {
        },
        success: function (data) {
            var optionStr = "<option value=''>州</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (provinceId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='dest_province_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}
/*
 * 得到城市
 */
function getDestCity(provinceId, cityId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getCityUrl,
        data: {
            province_id: provinceId
        },
        success: function (data) {
            var optionStr = "<option value='0'>城市</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (cityId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='dest_city_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}
/*
 * 得到区县
 */
function getDestDistrict(cityId, districtId, frm) {
    $.ajax({
        type: "GET",
        dataType: "json",
        url: getDistrictUrl,
        data: {
            "city_id": cityId
        },
        success: function (data) {
            var optionStr = "<option value='0'>区县</option>";
            for (var i in data) {
                optionStr = optionStr + "<option value = '" + data[i].id + "'" + (districtId == data[i].id ? " selected" : "") + ">" + data[i].name + "</option>";
            }
            $("select[name='dest_district_id']").html(optionStr);
            frm.render('select'); //刷新select选择框渲染
        }
    });
}

//改变省份
function changeDestProvince(provinceId, frm) {
    return;
    var optionStr = "<option value='0'>城市</option>";
    var optionCityStr = "<option value='0'>区县</option>";
    if (provinceId > 0) {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: getCityUrl,
            data: {
                province_id: provinceId
            },
            success: function (data) {
                var optionStr = "<option value='0'>城市</option>";
                for (var i in data) {
                    optionStr = optionStr + "<option value = '" + data[i].id + "'>" + data[i].name + "</option>";
                }
                $("select[name=dest_city_id]").html(optionStr);
                frm.render('select'); //刷新select选择框渲染
            }
        });
    } else {
        $("select[name=dest_city_id]").html(optionStr);
        frm.render('select'); //刷新select选择框渲染
    }
    $("select[name=dest_district_id]").html(optionCityStr);
    frm.render('select'); //刷新select选择框渲染
}

//改变区县
function changeDestCity(cityId, frm) {
    var optionStr = "<option value='0'>区县</option>";
    if (cityId > 0) {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: getDistrictUrl,
            data: {
                "city_id": cityId
            },
            success: function (data) {
                var optionStr = "<option value='0'>区县</option>";
                for (var i in data) {
                    optionStr = optionStr + "<option value = '" + data[i].id + "'>" + data[i].name + "</option>";
                }
                $("select[name=dest_district_id]").html(optionStr);
                frm.render('select'); //刷新select选择框渲染
            }
        });
    } else {
        $("select[name=dest_district_id]").html(optionStr);
        frm.render('select'); //刷新select选择框渲染
    }
}